<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .AA{
            width: 800px;
            height: 800px;
            background-color: pink;
            font-size: 100px;
        }
        .BB{
            width: 500px;
            height: 500px;
            background-color: springgreen;
        }
        .CC{
            width: 200px;
            height: 200px;
            background-color: skyblue;
        }
    </style>
</head>
<body>
    <div class="AA">爷爷
        <div class="BB">爸爸
            <div class="CC">儿子</div>
        </div>
    </div>
    <script>
        /* 
            如果,中间有一个没有点击,还会继续传播吗?
                是可以的
        */

        var a = document.querySelector(".AA")
        var b = document.querySelector(".BB")
        var c = document.querySelector(".CC")
        //事件的冒泡使用addEventListener来进行模拟
        // a.addEventListener("click",function(){
        //     console.log("爷爷");
        // // },true)  //事件的捕获
        // },false)  //事件的冒泡


        b.addEventListener("click",function(e){
            console.log("爸爸");
            //阻止事件的传播
            e.stopPropagation();
            e.cancelBubble
        // },true)
        },false)
        
        
        c.addEventListener("click",function(e){
            console.log("儿子");
            // },true)
        },false)

        document.body.onclick = function(){
            console.log("body");
        }

        document.documentElement.onclick = function(){
            console.log("HTML");
        }
        
        document.onclick = function(){
            console.log("document");
        }
        window.onclick = function(){
            console.log("window");
        }
    </script>
</body>
</html>